﻿
using System;
using System.Runtime.Serialization;

namespace Cheka.WinForm.Sample.Course
{
    [DataContract]
    public sealed class Course
    {
        // ==================================================== //
        #region "member variables"

        [DataMember]
        public string Semester { get; set; }

        [DataMember]
        public string Department { get; set; }

        [DataMember]
        public int Id { get; set; }

        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string Time { get; set; }

        [DataMember]
        public string Location { get; set; }

        #endregion

        // ==================================================== //
        #region "override methods"

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;

            if (object.ReferenceEquals(this, obj))
                return true;

            if (obj is Course)
            {
                Course otherCourse = (Course)obj;
                return this.Semester.Equals(otherCourse.Semester)
                    && this.Department.Equals(otherCourse.Department)
                    && this.Id == otherCourse.Id
                    && this.Name.Equals(otherCourse.Name)
                    && this.Time.Equals(otherCourse.Time)
                    && this.Location.Equals(otherCourse.Location);
            }
            else
                return false;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override string ToString() { return this.Name; }

        #endregion
    }
}